package edu.ssdut.revise.core.match;

import com.github.javaparser.utils.Pair;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * containing the matched and unmatched nodes of type T. Used in TwoFileMatcher.
 *
 * @param <T> the Type of nodes stored
 */
public class MatchStore<T> {
    private List<Pair<T, T>> matched = new ArrayList<>();   // TODO: BiMap
    private List<T> unmatchedNodes1 = new LinkedList<>();
    private List<T> unmatchedNodes2 = new LinkedList<>();

    public void insertMatched(Pair<T, T> pair) {
        matched.add(pair);
    }

    public void insertUnmatchedNodes1(T ele) {
        unmatchedNodes1.add(ele);
    }

    public void insertUnmatchedNodes2(T ele) {
        unmatchedNodes2.add(ele);
    }

    public void deleteUnmatchedNodes1(T ele) {
        unmatchedNodes1.remove(ele);
    }

    public void deleteUnmatchedNodes2(T ele) {
        unmatchedNodes2.remove(ele);
    }

    public List<Pair<T, T>> getMatched() {
        return matched;
    }

    public void setMatched(List<Pair<T, T>> matched) {
        this.matched = matched;
    }

    public List<T> getUnmatchedNodes1() {
        return unmatchedNodes1;
    }

    public void setUnmatchedNodes1(List<T> unmatchedNodes1) {
        this.unmatchedNodes1 = unmatchedNodes1;
    }

    public List<T> getUnmatchedNodes2() {
        return unmatchedNodes2;
    }

    public void setUnmatchedNodes2(List<T> unmatchedNodes2) {
        this.unmatchedNodes2 = unmatchedNodes2;
    }
}
